package com.lekang.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.annotation.Log;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.common.enums.BusinessType;
import com.lekang.domain.AssessmentReport;
import com.lekang.service.IAssessmentReportService;
import com.lekang.common.utils.poi.ExcelUtil;
import com.lekang.common.core.page.TableDataInfo;

/**
 * 评估报告Controller
 * 
 * @author wjy
 * @date 2025-10-15
 */
@RestController
@RequestMapping("/assessreport/report")
public class AssessmentReportController extends BaseController
{
    @Autowired
    private IAssessmentReportService assessmentReportService;

    /**
     * 查询评估报告列表
     */
    @PreAuthorize("@ss.hasPermi('assessreport:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssessmentReport assessmentReport)
    {
        startPage();
        List<AssessmentReport> list = assessmentReportService.selectAssessmentReportList(assessmentReport);
        return getDataTable(list);
    }

    /**
     * 导出评估报告列表
     */
    @PreAuthorize("@ss.hasPermi('assessreport:report:export')")
    @Log(title = "评估报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssessmentReport assessmentReport)
    {
        List<AssessmentReport> list = assessmentReportService.selectAssessmentReportList(assessmentReport);
        ExcelUtil<AssessmentReport> util = new ExcelUtil<AssessmentReport>(AssessmentReport.class);
        util.exportExcel(response, list, "评估报告数据");
    }

    /**
     * 获取评估报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('assessreport:report:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(assessmentReportService.selectAssessmentReportById(id));
    }

    /**
     * 新增评估报告
     */
    @PreAuthorize("@ss.hasPermi('assessreport:report:add')")
    @Log(title = "评估报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssessmentReport assessmentReport)
    {
        return toAjax(assessmentReportService.insertAssessmentReport(assessmentReport));
    }

    /**
     * 修改评估报告
     */
    @PreAuthorize("@ss.hasPermi('assessreport:report:edit')")
    @Log(title = "评估报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssessmentReport assessmentReport)
    {
        return toAjax(assessmentReportService.updateAssessmentReport(assessmentReport));
    }

    /**
     * 删除评估报告
     */
    @PreAuthorize("@ss.hasPermi('assessreport:report:remove')")
    @Log(title = "评估报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assessmentReportService.deleteAssessmentReportByIds(ids));
    }
}
